package com.ruoyi.system.service.impl;

import com.ruoyi.common.annotation.DataScope;
import com.ruoyi.common.core.domain.entity.SysStudent;
import com.ruoyi.common.core.domain.entity.SysUser;
import com.ruoyi.system.mapper.SysStudentMapper;
import com.ruoyi.system.service.ISysStudentService;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

/**
* @author:chengyu
* @date:2025/1/8
* @fun:业务处理层
*/
@Service
public class SysStudentServiceImpl implements ISysStudentService {
    private static final Logger log = LoggerFactory.getLogger(SysStudentServiceImpl.class);

    @Autowired
    private SysStudentMapper studentMapper;

    /**
     * 根据条件分页查询用户列表
     *
     * @param student 用户信息
     * @return 用户信息集合信息
     */
    @Override
    @DataScope(deptAlias = "d", userAlias = "u")
    public List<SysStudent> selectStudentList(SysStudent student) {
        return handleStudentData(studentMapper.selectStudentList(student));
    }

    /**
     * 对学生列表数据进行处理
     *
     * @param studentList 从数据库查询出来的学生列表
     * @return 处理后的学生列表
     */
    public List<SysStudent> handleStudentData(List<SysStudent> studentList) {
        for (SysStudent item : studentList) {
            if ("Male".equals(item.getGender())) {
                item.setGender("男");
            } else {
                item.setGender("女");
            }
        }
        return studentList;
    }
}
